#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
int T;
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	T=read();
	while(T--){
		int a=read(),b=read();
		if(!b||!a){
			puts("0");continue;
		}
		if(a<0&&b<0||a>0&&b>0){
			puts("0");continue;
		}
		int res=min(abs(a),abs(b));
		res=min(res,abs(a+b));
		printf("%lld\n",res);
	}
	return 0;
}
/*
1
-7 -999999993
*/
